home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 295_01 / blkio_.h < prev    next >
Text File  |  1989-12-28  |  3KB  |  115 lines

  1. /*    Copyright (c) 1989 Citadel    */
  2. /*       All Rights Reserved        */
  3.  
  4. /* #ident    "blkio_.h    1.2 - 89/10/31" */
  5.  
  6. /*man---------------------------------------------------------------------------
  7. NAME
  8.      blkio_.h - private header for blkio library
  9.  
  10. SYNOPSIS
  11.      #include "blkio_.h"
  12.  
  13. DESCRIPTION
  14.      This is a private header file included by the blkio library
  15.      modules.
  16.  
  17. ------------------------------------------------------------------------------*/
  18. #ifndef BLKIO_H_    /* prevent multiple includes */
  19. #define BLKIO_H_
  20.  
  21. /*#define DEBUG        /* switch to enable debugging for blkio library */
  22.  
  23. /* The HOST macro specifies the host operating system.  Currently supported   */
  24. /* systems are:                                                               */
  25. #define UNIX    (1)    /* UNIX */
  26. #define MSDOS    (2)    /* MS-DOS */
  27. #define HOST    MSDOS
  28.  
  29. /* The MSDOSC macro specifies the MS-DOS C compiler being used.  Currently    */
  30. /* supported compilers are:                                                   */
  31. #define TURBOC    (1)    /* Borland Turbo C */
  32. #define MSC    (2)    /* Microsoft C */
  33. #define MSQC    (3)    /* Microsoft Quick C */
  34. #define MSDOSC    TURBOC
  35.  
  36. #include <bool.h>
  37. #include "blkio.h"
  38.  
  39. /* tables */
  40. extern BLKFILE biob[BOPEN_MAX];    /* BLKFILE control struct table declaration */
  41.  
  42. /* BLKFILE bit flags */
  43. #define BIOOPEN          (03)    /* open status bits */
  44. #define BIOREAD          (01)    /* block file is open for reading */
  45. #define BIOWRITE      (02)    /* block file is open for writing */
  46. #define BIOUSRBUF      (04)    /* user supplied buffer */
  47. #define BIOERR        (0100)    /* error has occurred on this block file */
  48.  
  49. /* block_t bit flags */
  50. #define BLKREAD          (01)    /* block can be read */
  51. #define BLKWRITE      (02)    /* block needs to be written to disk */
  52. #define BLKERR        (0100)    /* error has occurred on this block */
  53.  
  54. /* function declarations */
  55. #if __STDC__ == 1
  56. int    b_alloc(BLKFILE *bp);
  57. #define    b_blkbuf(BP, N) ((void *)(                    \
  58.         (char *)(BP)->blkbuf +                    \
  59.         ((N) == 0 ? 0 : (BP)->hdrsize + ((N) - 1) * (BP)->blksize)\
  60. ))
  61. #define    b_block_p(BP, N) ((block_t *)(                    \
  62.         (char *)(BP)->block_p +    (N) * sizeof(block_t)        \
  63. ))
  64. void    b_free(BLKFILE *bp);
  65. int    b_get(BLKFILE *bp, size_t i);
  66. int    b_initlist(BLKFILE *bp);
  67. int    b_mkmru(BLKFILE *bp, size_t i);
  68. int    b_put(BLKFILE *bp, size_t i);
  69. bool    b_valid(const BLKFILE *bp);
  70.  
  71. int    b_uclose(BLKFILE *bp);
  72. int    b_uendblk(BLKFILE *bp, bpos_t *endblk_p);
  73. int    b_ugetf(BLKFILE *bp, bpos_t bn, size_t offset, void *buf, size_t bufsize);
  74. int    b_uopen(BLKFILE *bp, const char *filename, const char *type);
  75. int    b_uputf(BLKFILE *bp, bpos_t bn, size_t offset, const void *buf, size_t bufsize);
  76. #else
  77. int    b_alloc();
  78. #define    b_blkbuf(BP, N) ((void *)(                    \
  79.         (char *)(BP)->blkbuf +                    \
  80.         ((N) == 0 ? 0 : (BP)->hdrsize + ((N) - 1) * (BP)->blksize)\
  81. ))
  82. #define    b_block_p(BP, N) ((block_t *)(                    \
  83.         (char *)(BP)->block_p +    (N) * sizeof(block_t)        \
  84. ))
  85. void    b_free();
  86. int    b_get();
  87. int    b_initlist();
  88. int    b_mkmru();
  89. int    b_put();
  90. bool    b_valid();
  91.  
  92. int    b_uclose();
  93. int    b_uendblk();
  94. int    b_ugetf();
  95. int    b_uopen();
  96. int    b_uputf();
  97. #endif    /* #if __STDC__ == 1 */
  98.  
  99. /* block file open types */
  100. #define BF_READ        ("r")
  101. #define BF_RDWR        ("r+")
  102. #define BF_CRTR        ("w+")
  103. #define BF_CREATE    ("c")
  104.  
  105. #ifdef DEBUG
  106. #define    BEPRINT {                            \
  107.     fprintf(stderr, "blkio error line %d of %s.  errno = %d.\n",    \
  108.         __LINE__, __FILE__, errno);                \
  109. }
  110. #else
  111. #define BEPRINT
  112. #endif
  113.  
  114. #endif    /* #ifndef BLKIO_H_ */
  115.